﻿using System;
using System.Collections;
using BLL;

namespace MakeBabyWebApplication
{
    public partial class login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //只响应POST请求
            if (Request.HttpMethod == "POST")
            {
                string email = Request.Params["email"];
                string password = Request.Params["password"];

                //Response.Write("<script>alert('" + email + password + name + sex +".."+ "')</script>");
                //服务端非空检测
                if (email == "")
                {
                    Response.Write("<script>alert('email为空...')</script>");
                    return;
                }
                else if (password == "")
                {
                    Response.Write("<script>alert('email为空...')</script>");
                    return;
                }
                else
                {
                    //开始存入数据库
                    UserService userService = new UserService();
                    Hashtable ht = userService.login(email, password);
                    string result = (string)ht["result"];
                    string message = (string)ht["message"];
                    if (result == "1")
                    {
                        Response.Write("<script>alert('登陆成功')</script>");
                    }
                    else
                    {
                        Response.Write("<script>alert('" + "登陆失败-- "+ message + "')</script>");
                    }
                }
            }
        }
    }
}